home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_GetCommandWidth.c < prev    next >
C/C++ Source or Header  |  1996-03-18  |  848b  |  47 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_MENUS
  15.  
  16.     /* LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item):
  17.      *
  18.      *    Calculate the width of a command sequence.
  19.      */
  20.  
  21. LONG
  22. LTP_GetCommandWidth(RootMenu *Root,ItemNode *Item)
  23. {
  24.     LONG Width = 0;
  25.  
  26.         // Skip separator bars
  27.  
  28.     if(!(Item->Flags & ITEMF_IsBar))
  29.     {
  30.             // Add in the Amiga glyph
  31.  
  32.         if(Item->Item.Flags & COMMSEQ)
  33.             Width = TextLength(&Root->RPort,&Item->Item.Command,1) + 2 + Root->AmigaWidth + 2;
  34.         else
  35.         {
  36.                 // Add in command or submenu indicator
  37.  
  38.             if(Item->Flags & (ITEMF_Command | ITEMF_HasSub))
  39.                 Width = IntuiTextLength(((struct IntuiText *)Item->Item.ItemFill)->NextText) + 2;
  40.         }
  41.     }
  42.  
  43.     return(Width);
  44. }
  45.  
  46. #endif    /* DO_MENUS */
  47.